package com.rem.hutool.my5Utils;

import cn.hutool.core.util.ReflectUtil;
import lombok.Data;

import java.lang.reflect.Method;

/**
 * 反射工具
 *
 * @author Rem
 * @date 2020-08-21
 */

public class ReflectUtilDemo {

    public static void main(String[] args) {
        Method[] methods = ReflectUtil.getMethods(Object.class);
        System.err.println(methods.length);

        Method toString = ReflectUtil.getMethod(Object.class, "toString");
        System.err.println(toString.getName());

        Object toString1 = ReflectUtil.invoke(Object.class, "toString");
        System.err.println(toString1);


        A a = ReflectUtil.newInstance(A.class);
        ReflectUtil.invoke(a, "setName", "jack");
        System.err.println(a.toString());
    }


    @Data
    static class A {
        private int age;
        private String name;
    }
}
